package com.hontech.cross.test

import android.annotation.SuppressLint
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {

    private lateinit var mWebView: WebView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        mWebView = findViewById(R.id.id_web_view)
        init()
    }

    @SuppressLint("SetJavaScriptEnabled")
    private fun init() {
        val setting = mWebView.settings
        setting.javaScriptEnabled = true
        setting.domStorageEnabled = true
        setting.useWideViewPort = true
        setting.loadWithOverviewMode = true
        mWebView.webViewClient = WebViewClient()

        mWebView.loadUrl("http://127.0.0.1:8080/web/index.html")
    }

}


